package com.hackathon.sgstern.model;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.UUID;

import com.google.android.gms.maps.model.LatLng;

public class SportEvent implements Serializable {
	private static final long serialVersionUID = 7616724098051236172L;

	private final UUID uuid = UUID.randomUUID();
	public String title;
	public Sports art;
	private double latitude;
	private double longitude;
	public Date time;
	public int minTeilnehmer;
	public int maxTeilnehmer;
	public long dauer;
	public boolean privateEvent = false;
	public Person creator;
	public final List<Person> participants = new ArrayList<Person>();

	@Override
	public String toString() {
		SimpleDateFormat format = new SimpleDateFormat("dd.MM hh:mm",
				Locale.GERMANY);
		if (time != null) {
			return title + "   :   " + format.format(time);
		} else {
			return title;
		}
	}

	public void setOrt(LatLng latLng) {
		latitude = latLng.latitude;
		longitude = latLng.longitude;
	}

	public LatLng getOrt() {
		return new LatLng(latitude, longitude);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SportEvent other = (SportEvent) obj;
		if (uuid == null) {
			if (other.uuid != null)
				return false;
		} else if (!uuid.equals(other.uuid))
			return false;
		return true;
	}
	


}
